// directInfo.js
var app = getApp()
Page({

   /**
    * 页面的初始数据
    */
   data: {
     
   },

   /**
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
      var that = this;
      wx.request({
         url: app.globalData.allUrl + '/YMGW/directAction/getDirectInfoById',
         data: {
            directId: options.directId
         },
         method: 'GET',
         success: function (res) {
            console.log(res.data);
            that.setData({
               Object: res.data
            })
         }
      })
   },

   /**
    * 生命周期函数--监听页面初次渲染完成
    */
   onReady: function () {

   },

   /**
    * 生命周期函数--监听页面显示
    */
   onShow: function () {

   },

   /**
    * 生命周期函数--监听页面隐藏
    */
   onHide: function () {

   },

   /**
    * 生命周期函数--监听页面卸载
    */
   onUnload: function () {

   },

   /**
    * 页面相关事件处理函数--监听用户下拉动作
    */
   onPullDownRefresh: function () {

   },

   /**
    * 页面上拉触底事件的处理函数
    */
   onReachBottom: function () {

   },

   /**
    * 用户点击右上角分享
    */
   onShareAppMessage: function () {

   },
   calling: function () {
      var that = this;
      //   console.log(that.data.Object.phone);
      wx.makePhoneCall({
         phoneNumber: that.data.Object.phone, //此号码并非真实电话号码，仅用于测试
         success: function () {
            console.log("拨打电话成功！")
         },
         fail: function () {
            console.log("拨打电话失败！")
         }
      })
   },
   infoImgClick: function (e) {     
      var that = e.target.dataset.id;      
      var objects = this.data.Object;
      var urls = [];
      var str = "https://www.ymg3.com/ymgImage/directs/";
      urls.push(str + objects.licenseImg);
      urls.push(str + objects.identityCardImg);
      urls.push(str + objects.brandImg);
      wx.previewImage({
         current: urls[that], // 当前显示图片的http链接
         urls: urls
      })
   }
})